package com.donfu.web.controller.house;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.donfu.common.annotation.Log;
import com.donfu.common.core.controller.BaseController;
import com.donfu.common.core.domain.AjaxResult;
import com.donfu.common.enums.BusinessType;
import com.donfu.system.domain.house.HouseNotice;
import com.donfu.system.service.house.IHouseNoticeService;
import com.donfu.common.utils.poi.ExcelUtil;
import com.donfu.common.core.page.TableDataInfo;

/**
 * 通知信息Controller
 * 
 * @author donfu
 * @date 2021-12-01
 */
@RestController
@RequestMapping("/house/notice")
public class HouseNoticeController extends BaseController
{
    @Autowired
    private IHouseNoticeService houseNoticeService;

    /**
     * 查询通知信息列表
     */
    @PreAuthorize("@ss.hasPermi('house:notice:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseNotice houseNotice)
    {
        startPage();
        List<HouseNotice> list = houseNoticeService.selectHouseNoticeList(houseNotice);
        return getDataTable(list);
    }

    /**
     * 导出通知信息列表
     */
    @PreAuthorize("@ss.hasPermi('house:notice:export')")
    @Log(title = "通知信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HouseNotice houseNotice)
    {
        List<HouseNotice> list = houseNoticeService.selectHouseNoticeList(houseNotice);
        ExcelUtil<HouseNotice> util = new ExcelUtil<HouseNotice>(HouseNotice.class);
        return util.exportExcel(list, "通知信息数据");
    }

    /**
     * 获取通知信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('house:notice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(houseNoticeService.selectHouseNoticeById(id));
    }

    /**
     * 新增通知信息
     */
    @PreAuthorize("@ss.hasPermi('house:notice:add')")
    @Log(title = "通知信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseNotice houseNotice)
    {
        return toAjax(houseNoticeService.insertHouseNotice(houseNotice));
    }

    /**
     * 修改通知信息
     */
    @PreAuthorize("@ss.hasPermi('house:notice:edit')")
    @Log(title = "通知信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseNotice houseNotice)
    {
        return toAjax(houseNoticeService.updateHouseNotice(houseNotice));
    }

    /**
     * 删除通知信息
     */
    @PreAuthorize("@ss.hasPermi('house:notice:remove')")
    @Log(title = "通知信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(houseNoticeService.deleteHouseNoticeByIds(ids));
    }
}
